package com.itheima.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

public class MyBatisConfig {


     @Bean
    public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource){

        SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();

        factoryBean.setTypeAliasesPackage("com.itheima.pojo");
        factoryBean.setDataSource(dataSource);
        return factoryBean;

    }
    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer(){

        MapperScannerConfigurer ms = new MapperScannerConfigurer();

        ms.setBasePackage("com.itheima.dao");

        return ms;

    }
}
